#include "GameObject.h"

/*********************************************************************************
*
*	Constructor
*	posX: Position X of Object
*	posY: Position Y of Object
*	width: Width of Object
*	height: Heigh of Object
*	res: Pointer Resources
*
**********************************************************************************/
GameObject::GameObject(int posX, int posY, int width, int height, Resources* res, int number, int depth)
{
	_resources = res;

	_pos_x = posX;
	_pos_y = posY;
	_old_x = _pos_x;
	_old_y = _pos_y;

	_number = number;

	_width = width;
	_height = height;
	_sprite = NULL;

	_depth = depth;
	_isAlive = true;
	TimeCollision = 0;
	ResetRect();
	_old_rect = _rect;
}

/*********************************************************************************
*
*	Destructor
*	Delete all pointers were created in Game.
*
**********************************************************************************/
GameObject::~GameObject()
{
	if (_sprite->Height() > 0)
		delete _sprite;
}

/************************************************************************************************
*
*	Update
*	Update all state of Object
*	It is a vitural Method
*	time: Time of a Frame
*	listObj: List dynamic Objects in Viewport, use for check collision
*	stListObj: List static Objects in Viewpoer, use for check collision in Moving
*
*************************************************************************************************/
void GameObject::Update(float time, QNode* &Tree)
{

}

/************************************************************************************************
*
*	Render
*	Draw Object
*	It is a vitural Method
*	spriteHandler: use for Render Object in DirectX
*	viewport: Viewport, get some arguments use for translation in Sprite
*
*************************************************************************************************/
void GameObject::Render(LPD3DXSPRITE spriteHandler, Viewport* viewport)
{

}

/************************************************************************************************
*
*	ResetRect
*	Update Rectangle bounding Object
*
*************************************************************************************************/
void GameObject::ResetRect()
{
	_rect.left = _pos_x - _width / 2;
	_rect.top = _pos_y + _height / 2;
	_rect.right = _rect.left + _width;
	_rect.bottom = _rect.top - _height;
}

/************************************************************************************************
*
*	ChangeState
*	Change state of Object
*	state: State of Object
*
*************************************************************************************************/
void GameObject::ChangeState(char state)
{

}
